local ExpBooster = Class(function(self, inst)
    self.inst = inst

    local classified = inst.player_classified
    if TheWorld.ismastersim then
        self.classified = classified
    elseif classified and self.classified == nil then
        self:AttachClassified(classified)
    end
end)

function ExpBooster:AttachClassified(classified)
    self.classified = classified
    self.ondetachclassified = function() self:DetachClassified() end
    self.inst:ListenForEvent("onremove", self.ondetachclassified, classified)
end

function ExpBooster:DetachClassified()
    self.classified = nil
    self.ondetachclassified = nil
end

function ExpBooster:SetCurrentLevel(current)
    if self.classified ~= nil then
        self.classified:SetValue("assn_currentlevel", current)
    end
end

function ExpBooster:SetMaxLevel(max)
    if self.classified ~= nil then
        self.classified:SetValue("assn_maxlevel", max)
    end
end

function ExpBooster:SetCurrentExp(current)
    if self.classified ~= nil then
        self.classified:SetValue("assn_currentexp", current)
    end
end

function ExpBooster:GetCurrentLevel()
    if self.inst.components.expbooster ~= nil then
        return self.inst.components.expbooster.level
    elseif self.classified ~= nil then
        return self.classified.assn_currentlevel:value()
    else
        return 0
    end
end

function ExpBooster:GetCurrentExp()
    if self.inst.components.expbooster ~= nil then
        return self.inst.components.expbooster.exp
    elseif self.classified ~= nil then
        return self.classified.assn_currentexp:value()
    else
        return 0
    end
end

return ExpBooster
